package com.twu.stub;

import java.io.BufferedReader;
import java.io.Reader;

/**
 * Created with IntelliJ IDEA.
 * User: root
 * Date: 6/28/13
 * Time: 1:35 AM
 * To change this template use File | Settings | File Templates.
 */
public class StubBufferRead extends BufferedReader {


    private String[] content;
    private int lineNumber;

    public static StubBufferRead createStubBufferRead(String input){
        StubBufferRead reader = new StubBufferRead(new MyReader(), 1);
        reader.setContent(input);
        return reader;
    }

    public StubBufferRead(Reader in, int sz) {
        super(in, sz);
    }

    public void setContent(String content){
        this.content = content.split("\n");
        this.lineNumber = 0;
    }

    public String readLine(){
        return lineNumber == content.length ? "" : content[lineNumber++];
    }
}
